package com.jianganming.mediator;

import java.util.HashMap;
import java.util.Map;

//这里采用了Spring的容器思想
public class Registry {
    private Map<String,IService> map = new HashMap<>();
    private static Registry registry = new Registry();

    private Registry(){
        map.put("serviceA",new ServiceA());
        map.put("serviceB",new ServiceB());
        map.put("serviceC",new ServiceC());
    }

    public static Registry getInstance(){
        return registry;
    }

    public IService getObject(String serviceName){
        return map.get(serviceName);
    }
}
